home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ZOOM_EX.ZIP / ZOOM1.ASM < prev    next >
Assembly Source File  |  1993-12-25  |  6KB  |  256 lines

  1. ;                                                       (C)ode by Nic of IMP
  2.  
  3. JUMPS
  4. SMART
  5. LOCALS
  6. DOSSEG
  7.  
  8. ;───────────────────────────────────────────────────────────────────────────────
  9. ;███████████████████████████████████████████████████████████████████████████████
  10. ;───────────────────────────────────────────────────────────────────────────────
  11.  
  12. Time    =       0       ; to show time equal this to unity
  13.  
  14. ; some usefull macro's
  15.  
  16. ; only for Motorola freaks !
  17.  
  18. movB    MACRO    dst,src
  19.     mov BYTE PTR    dst,src
  20.     ENDM
  21.  
  22. movW    MACRO    dst,src
  23.     mov WORD PTR    dst,src
  24.     ENDM
  25.  
  26. movL    MACRO    dst,src
  27.     mov DWORD PTR    dst,src
  28.     ENDM
  29.  
  30. WaitKey MACRO
  31.     mov    ah,7
  32.     int    21h
  33.     ENDM
  34.  
  35. PrintString MACRO String
  36.     mov    dx,OFFSET String
  37.     mov    ah,9
  38.     int    21h
  39.     ENDM
  40.  
  41. Exit2Dos MACRO    ErrCode
  42.     mov    ax,4c00h+ErrCode
  43.     int    21h
  44.     ENDM
  45.  
  46. Color   MACRO   Num,RComp,GComp,BComp
  47.         push    dx
  48.         push    ax
  49.         mov     dx,3c8h
  50.         mov     al,Num
  51.         out     dx,al
  52.         mov     dx,3c9h
  53.         mov     al,RComp
  54.         out     dx,al
  55.         mov     al,GComp
  56.         out     dx,al
  57.         mov     al,BComp
  58.         out     dx,al
  59.         pop     ax
  60.         pop     dx
  61.         ENDM
  62.  
  63. ;───────────────────────────────────────────────────────────────────────────────
  64. ;███████████████████████████████████████████████████████████████████████████████
  65. ;───────────────────────────────────────────────────────────────────────────────
  66.  
  67. StackSeg    Segment Para USE16 STACK 'STACK'
  68.     DW    512 DUP (?)
  69. StackSeg    Ends
  70.  
  71. ;───────────────────────────────────────────────────────────────────────────────
  72.  
  73. DataSeg     Segment Para USE16 'DATA'
  74.  
  75. CodeString    DB 80 DUP (0)
  76.  
  77.         ALIGN   16
  78. Picture         LABEL
  79.                 INCLUDE TestZoom.pic
  80.                 DB 320 DUP (0)
  81.  
  82. DataSeg     Ends
  83.  
  84. ;═══════════════════════════════════════════════════════════════════════════════
  85.  
  86. CodeSeg     Segment Para USE16 'CODE'
  87.     ASSUME    cs:CodeSeg , ds:DataSeg , ss:StackSeg
  88.  
  89. Prog    Proc Far
  90.     call    SetFree
  91.  
  92.     mov    ax,DataSeg
  93.     mov    ds,ax
  94.     mov    es,ax
  95.     cld
  96.         call    InitGfxMode
  97.         call    InstallColors
  98.  
  99. ;═══════════════════════════════════════════════════════════════════════════════
  100.         call    TstZoom
  101. ;═══════════════════════════════════════════════════════════════════════════════
  102.  
  103.     WaitKey
  104.         call    RestTxtMode
  105.  
  106. Finish: Exit2Dos    0
  107.  
  108. Prog    Endp
  109.  
  110. ;───────────────────────────────────────────────────────────────────────────────
  111. ;███████████████████████████████████████████████████████████████████████████████
  112. ;───────────────────────────────────────────────────────────────────────────────
  113.  
  114. ; here, we'll just make a vertical zoom, it is faster, but it's not for that,
  115. ; I think it will be easier to understant if you have only one zoom & I've
  116. ; tried to keep my code clean & short.
  117.  
  118. OriginalSize    DW      200
  119. DestinationSize DW      0
  120. Count           DW      ?
  121. LineLength      =       320     ; in bytes
  122.  
  123. TstZoom PROC NEAR
  124.  
  125. VBLLoop:
  126.         mov     dx,3dah         ; wait VBL
  127. Wait1:  in      al,dx
  128.         test    al,8
  129.         jne     Wait1
  130. Wait2:  in      al,dx
  131.         test    al,8
  132.         je      Wait2
  133.  
  134.         IF      Time
  135.         Color   0,20,0,0
  136.         ENDIF
  137.                                 ; Zoom the Pic
  138.         mov     ax,0a000h
  139.         mov     es,ax
  140.         mov     di,0
  141.         lea     si,Picture
  142.         inc     DestinationSize
  143.         cmp     DestinationSize,201
  144.         jl      GoodSize
  145.         mov     DestinationSize,1
  146.         call    ClearScreen
  147. GoodSize:
  148.         mov     cx,DestinationSize
  149.         mov     Count,cx
  150.         mov     ax,OriginalSize
  151.         mov     bx,DestinationSize
  152.         mov     bp,LineLength
  153.  
  154. ; the 2 following lines are here to make a better approx
  155.         mov     dx,ax
  156.         shr     dx,1
  157.  
  158. ZoomLoop:
  159.         add     dx,bx
  160.         add     si,bp
  161.         cmp     dx,ax
  162.         jl      ZoomLoop
  163.         sub     dx,ax
  164.  
  165. CopyOneLine:
  166.         mov     cx,LineLength/2
  167.         REP     movsw
  168.         sub     si,bp
  169.  
  170.         dec     Count
  171.         jnz     ZoomLoop
  172.  
  173.         IF      Time
  174.         Color   0,0,0,0
  175.         ENDIF
  176.                                 ; Zoom the Pic
  177.         in      al,60h          ; read key
  178.         cmp     al,039h
  179.         jne     VBLLoop
  180.  
  181.         ret
  182. TstZoom ENDP
  183.  
  184. ClearScreen PROC NEAR
  185.         mov     ax,0a000h
  186.         mov     es,ax
  187.         mov     ax,0
  188.         mov     cx,320*200/2
  189.         REP     stosw
  190.         ret
  191. ClearScreen ENDP
  192.  
  193. ;───────────────────────────────────────────────────────────────────────────────
  194. ;███████████████████████████████████████████████████████████████████████████████
  195. ;───────────────────────────────────────────────────────────────────────────────
  196.  
  197. ; release memory
  198.  
  199. SetFree PROC NEAR
  200.     mov    bx,ss
  201.     mov    ax,es
  202.     sub    bx,ax
  203.     mov    ax,sp
  204.     add    ax,15
  205.     mov    cl,4
  206.     shr    ax,cl
  207.     add    bx,ax
  208.     mov    ah,4ah
  209.     int    21h
  210.     ret
  211. SetFree ENDP
  212.  
  213. ;───────────────────────────────────────────────────────────────────────────────
  214.  
  215. InstallColors PROC NEAR
  216.         push    ds
  217.         push    cs
  218.         pop     ds
  219.         lea     si,PALETTE
  220.         mov     cx,256
  221.         mov     dx,03c8h
  222.         xor     al,al
  223.         out     dx,al
  224.         inc     dx
  225.         cld
  226. @@ColorLoop:
  227.         lodsb
  228.         shr     al,3
  229.         out     dx,al
  230.         loop    @@ColorLoop
  231.         pop     ds
  232.         ret
  233. InstallColors ENDP
  234.  
  235. PALETTE LABEL
  236.         INCLUDE testzoom.pal
  237.  
  238. InitGfxMode PROC NEAR
  239.         mov     ax,13h
  240.         int     10h
  241.         ret
  242. InitGfxMode ENDP
  243.  
  244. RestTxtMode PROC NEAR
  245.         xor     ah,ah
  246.         mov     al,03h
  247.         int     10h
  248.         ret
  249. RestTxtMode ENDP
  250.  
  251.  
  252. ;═══════════════════════════════════════════════════════════════════════════════
  253.  
  254. CodeSeg     Ends
  255.     END    Prog
  256.